package com.dongdongshop.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.dongdongshop.mapper.TbTypeTemplateMapper;
import com.dongdongshop.pojo.typeTemplate.TbTypeTemplate;
import com.dongdongshop.pojo.typeTemplate.TbTypeTemplateExample;
import com.dongdongshop.service.TemplateServiceI;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Component
@Service
public class TemplateServiceImpl implements TemplateServiceI {
    @Resource
    private TbTypeTemplateMapper templateMapper;


    @Override
    public TbTypeTemplate updateById(Long id) {
        return templateMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<TbTypeTemplate> findAll() {
        return templateMapper.selectByExample(new TbTypeTemplateExample());
    }

    @Override
    public int updateTemplate(TbTypeTemplate tbTypeTemplate) {
       return templateMapper.updateByPrimaryKeySelective(tbTypeTemplate);
    }

    @Override
    public TbTypeTemplate getTempById(Long id) {
        return templateMapper.selectByPrimaryKey(id);
    }

    @Override
    public void insertTemplate(TbTypeTemplate tbTypeTemplate) {
        templateMapper.insertSelective(tbTypeTemplate);
    }

    @Transactional
    @Override
    public int deleteTemplates(Integer[] ids) {
        return templateMapper.deleteTemplates(ids);
    }

    @Override
    public List<TbTypeTemplate> templateList(String name) {
        return templateMapper.selectByName(name);
    }
}
